﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

<script>

    



    


     async function btnInsertFormAllAwait()
    {
        const form = document.querySelector('form');

        const data = new FormData(form);
          
        const response = await  fetch('/Notice/Insert',
        {
            method:'POST',
              // headers: {
              //    'Content-Type': 'application/json;charset=utf-8'
              //   },
                    body: data

          });

          const json = await response.json();
          
          console.log("json 的结果");
          console.log(json);
          if(json.status==200)
          {
              alert(json.message);
          }
          else
          {
              alert("添加失败");
          }

          
    }



    


    

    


</script>

<form>

    <table style="width:96%;">
        <tbody>
            <tr>
                <th width="80">id</th>
                <td>自动生成</td>
            </tr>
            <tr>
                <th>title</th>
                <td><input class="input-group" type="text" id="title" name="title" /></td>
            </tr>
            <tr>
                <th>content</th>
                <td>
                    <textarea id="content" name="content" rows="10" style="width:100%;"></textarea>
                    </td>
            </tr>
            <tr>
                <th></th>
                <td>
                    @* <input type="button" class="btn btn-primary" value="新增" onclick="btnInsert()" />
                    <input type="button" class="btn btn-dark" value="新增从form" onclick="btnInsertForm()" />
                    <input type="button" class="btn btn-success" value="新增从formAll" onclick="btnInsertFormAll()" /> *@
                    <input type="button" class="btn btn-danger" value="btnInsertFormAllAwait" onclick="btnInsertFormAllAwait()" />
                    @* <input type="button" class="btn btn-danger" value="新增从formSelf" onclick="btnInsertFormSelf()" /> *@
                </td>
            </tr>
        </tbody>
    </table>


</form>
